package com.tymchak.user.backingbeans;

import java.util.List;

import javax.ejb.EJB;
import com.tymchak.DAO.ProjectDAO;
import com.tymchak.DAO.UserDAO;
import com.tymchak.entity.Project;
import com.tymchak.entity.User;

public class UserMainPrimefaces {

        @EJB
        private ProjectDAO projectDAO;
        @EJB
        private UserDAO userDAO;
       
        private List<Project> projects;
       
        private Project selectedProject;
        private Project newProject;
       
        public UserMainPrimefaces(){
                selectedProject = new Project();
                newProject = new Project();
        }

        public void addNewProject(){
               
                User user = userDAO.read();
                newProject.setUser(user);
               
                projectDAO.create(newProject);
               
                newProject = new Project();
        }
       
        //gs
       
        public List<Project> getProjects() {
               
                User user = userDAO.read();
               
                projects = projectDAO.getUserProjects(user, 0, 0);
                return projects;
        }

        public void setProjects(List<Project> projects) {
                this.projects = projects;
        }

        public Project getSelectedProject() {
                return selectedProject;
        }

        public void setSelectedProject(Project selectedProject) {
                this.selectedProject = selectedProject;
        }

        public Project getNewProject() {
                return newProject;
        }

        public void setNewProject(Project newProject) {
                this.newProject = newProject;
        }
       
}
